import java.io.IOException;

import org.kwis.msp.lcdui.Jlet;
import org.kwis.msp.lcdui.Display;
import org.kwis.msp.lcdui.Image;

import org.kwis.msp.lwc.Component;
import org.kwis.msp.lwc.ShellComponent   ;
import org.kwis.msp.lwc.ButtonComponent   ;
import org.kwis.msp.lwc.LabelComponent;
import org.kwis.msp.lwc.ActionListener ;


public class ButtonComponentEx2 extends Jlet{

	class ActionListenerHandler implements ActionListener {

		public void action(Component cmp , Object obj){

			Image imgButton2 = null;

			try{
				imgButton2 = Image.createImage("/button2.gif");
			}catch(IOException e){
				System.out.println(e);
			}


			ShellComponent shell = (ShellComponent)obj;
			LabelComponent lb1 = new LabelComponent("  OK Button Pressed");
			LabelComponent lb2 = new LabelComponent("   ¤»¤»¤»",imgButton2);
			
			shell.setTitle(lb1);
			shell.setWorkComponent(lb2);
	
		}
	
	}

	Display displayLCD ;
		

	public ButtonComponentEx2(){      }

	protected void startApp(String[] arg0){
		
		displayLCD = Display.getDefaultDisplay();
		ShellComponent shell = new ShellComponent();

		Image imgButton = null;

		try{
			imgButton = Image.createImage("/button1.gif");
		}catch(IOException e){
			System.out.println(e);
		}

		ButtonComponent button = new ButtonComponent("   Button",imgButton);

		button.setActionListener(new ActionListenerHandler(),shell);

		shell.setCommand(button,false);

		displayLCD.pushCard(shell.getCard());

	}


	protected void destroyApp(boolean arg0) {  }

	

}
